package com.ruoyi.project.check.controller;

import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.check.domian.Hoscheck;
import com.ruoyi.project.check.service.IHoscheckservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("project/check")
public class HosCheckController extends BaseController {

    @Autowired
    private IHoscheckservice iHoscheckservice;

    /**
     * 页面数据显示
     * @param hoscheck
     * @return
     */
    @PreAuthorize("@ss.hasPermi('project:check:list')")
    @GetMapping("/list")
    public TableDataInfo list(Hoscheck hoscheck){
        startPage();
        List<Hoscheck> list = iHoscheckservice.selectHosChecklist(hoscheck);
        return getDataTable(list);
    }
    /**
     * 结果录入
     * @param hoscheck
     * @return
     */
    @PreAuthorize("@ss.hasPermi('project:check:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Hoscheck hoscheck){
        return toAjax(iHoscheckservice.insertHosCheck(hoscheck));
    }


    @PreAuthorize("@ss.hasPermi('project:check:query')")
    @GetMapping(value = "/{checkId}")
    public AjaxResult getInfo( @PathVariable("checkId") Long checkId){
        return AjaxResult.success(iHoscheckservice.selectHosCheckById(checkId));
    }

    @PreAuthorize("@ss.hasPermi('project:check:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Hoscheck hoscheck){
        return AjaxResult.success(iHoscheckservice.updateHosCheck(hoscheck));
    }


}
